$('#title').html('还款计划');
Cardlist.generationPlan({ //生成还款计划
	method:'plan.preview',
	version: '1.0.2',
	userId: localStorage.rpUserId,
	bundCardId: sessionStorage.bankCardId,
	reDates: sessionStorage.reDates,
	totalAmount: sessionStorage.totalAmont
},function(res){
			html = template.render("template_details", res);
			$('#details').html(html);
});

	// 重新生成
	$('.details-foot-left').click(function(){
		Cardlist.generationPlan({ //生成还款计划
			method:'plan.preview',
			version: '1.0.2',
			userId: localStorage.rpUserId,
			bundCardId: sessionStorage.bankCardId,
			reDates: sessionStorage.reDates,
			totalAmount: sessionStorage.totalAmont
		},function(res){
			html = template.render("template_details", res);
			$('#details').html(html);
		});
	});
	// 下一步
	$('.details-foot-right').click(function(){
		if(sessionStorage.isOpenQuick == 0){
		  $('.tips').html('<p>验证码将会发送至'+sessionStorage.phoneNo+'</p>')
		  $('#model').show();
		  $('.getems').click(function(){ //获取鉴权验证码
		  	 VerifyCode.getVerifyCode({
		    	method: 'plan.sendsms',
		    	version: '1.0.2',
		    	userId: localStorage.rpUserId, 
		    	bundCardId: sessionStorage.bankCardId, //银行卡id
		    	cardType: 1 //卡类型，0=储蓄卡，1=信用卡
		    },function(res){});
		  });
		}else{
			// 已鉴权直接跳转,并将相关参数传入
			location.hash = 'pay';
		}
	});
	//model框取消
	$('.Boxcancel').click(function(){
		$('#model').hide();
	});
	
	//完成鉴权 并跳转支付
	$('.Boxconfirm').click(function(){
		var verifyCode = $('#VerifyCode').val();
		if(verifyCode != ''){
			VerifyCode.planOpenQuick({ //鉴权
				method: 'plan.openquick',
				version: '1.0.2',
				userId: localStorage.rpUserId,
				bundCardId: sessionStorage.bankCardId,
				cardType: 1,
				verifyCode: verifyCode 
			},function(res){
				sessionStorage.isOpenQuick = 1; //鉴权成功后写入缓存
				Cardlist.planConfirm({ //确认计划
					method:'plan.confirm',
					version: '1.0.2',
					userId: localStorage.rpUserId,
					bundCardId: sessionStorage.bankCardId, //银行卡CardId
					batchNo: sessionStorage.batchNo //批次号
				},function(res){
					location.hash = 'pay';
				});
			});
		}else{
			layer.open({content: '验证码不能为空' ,skin: 'msg',time: 2});
		}
	});



